package com.zhijian.warehouse.manage.controller;

import com.zhijian.response.annotation.Response;
import com.zhijian.warehouse.manage.entity.vo.response.AccessDoorDeployVo;
import com.zhijian.warehouse.manage.service.AccessOptService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;

/**
 * 通道门设置 控制层
 *
 * @author auto
 * @version 1.0
 * @date 2024-11-03 15:31:18
 */
@Slf4j
@Controller
@Api(tags = "通道门连接")
public class SseMessageController {

    @Autowired
    private AccessOptService service;


    /**
     * 连接通道门
     *
     * @param param
     * @return
     */
    @Response
    @GetMapping("/access/door/connect/deploy/{id}")
    @ApiOperation("通道门连接")
    public SseEmitter doorConnect(@PathVariable("id") Long id) {
        //log.info("{} - {}| update info, {}", this.getClass().getSimpleName(), id, param);
        return service.doorConnect(AccessDoorDeployVo.builder().id(id).build());
    }

    /**
     * 关闭连接
     *
     * @param id
     * @param param
     * @return
     */
    @Response
    @PutMapping("/access/door/close/deploy/{id}")
    //@ApiOperation("关闭连接")
    public void closeDoorConnect(@PathVariable("id") Long id, @RequestBody AccessDoorDeployVo param) {
        log.info("{} - {}| update info, {}", this.getClass().getSimpleName(), id, param);
        param.setId(id);
        service.closeDoorConnect(param);
    }
}
